import EndingAnimation from "../EndingAnimation";
import GameManager from "../GameManager";
import Tween_breathe from "../Tween/Tween_breathe";

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    // onLoad () {}

    start() {

    }

    // update (dt) {}

    //同意收留
    OnYesBtnClicked() {
        this.node.active = false;
        GameManager.Instance.SharkSay([108, 109], () => {
            EndingAnimation.PlayEndingAnimation(9);
        })
    }

    //拒绝收留
    OnNoBtnClicked() {
        this.node.active = false;
        GameManager.Instance.SharkSay([114, 115], () => {
            let liulang = GameManager.GetNode("room/流浪鲨鱼");
            liulang.getComponent(Tween_breathe).TweenId.stop();
            liulang.scaleX = -GameManager.Instance.SharkNode.scaleX;
            cc.tween(liulang)
                .delay(0.3)
                .to(2, { position: cc.v3(liulang.x + GameManager.Instance.GameNode.getContentSize().width / 2 - 150, liulang.y) })
                .call(() => {
                    GameManager.Instance.SharkSay([116, 117], () => {
                        cc.tween(liulang)
                            .to(1, { position: cc.v3(cc.view.getVisibleSize().width / 2, liulang.y) })
                            .call(() => {
                                EndingAnimation.PlayEndingAnimation(10);
                            })
                            .start()
                    })
                })
                .start()
        })
    }
}
